$(function(){
        //验证码倒计时
        var getCode=document.getElementsByClassName("getCode")[0];
        var wait=60;
        function time(o) {
            if (wait == 0) {
                o.removeAttribute("disabled");
                o.value="获取短信验证码";
                o.style.color='#fff';
                o.style.cursor='pointer'
                wait = 60;
            }else {
                o.setAttribute("disabled", true);
                o.value=wait+"秒后重新获取";
                o.style.color='#a3a3a3';
                o.style.cursor='wait';
                wait--;
                setTimeout(function() {
                        time(o)
                    },
                    1000)
            }
        }
        getCode.onclick=function(){time(this);}


        //输入账户名验证
        var e = "<i class='fa fa-minus-circle'></i> ";
        $.validator.addMethod("isMobile",
            function(value, element) {
                var length = value.length;
                var mobile = /^(((1[0-9][0-9]{1})|(15[0-9]{1}))+\d{8})$/;
                return this.optional(element) || (length == 11 && mobile.test(value));
            });//手机号码格式
        $.validator.addMethod('isSpace',function(value,element){
            return this.optional(element)|| /^[^\s'"!@#$%]+$/.test(value)
        })
        $('#userNameForm').validate({
            submitHandler:function(form){
                $('#authenticateForm').show();
                $($('.reg-nav ul li')[1]).attr('class','active')
                $($('.reg-nav ul li')[0]).attr('class','')
                $(form).hide();
                time(getCode)
                //form.submit();
            },
            rules:{
                userName:{
                    required:true,
                },
                feedCode: {
                    required: true,
                },
            },
            messages: {
                userName: {
                    required: e + "请输入您的用户名",
                },
                feedCode: {
                    required: e + "请输入验证码",
                },
            },
        })
        //手机验证码验证
        $('#authenticateForm').validate({
            submitHandler:function(form){
                $('#setNewPswForm').show();
                $($('.reg-nav ul li')[2]).attr('class','active')
                $($('.reg-nav ul li')[1]).attr('class','')
                $(form).hide();
                //form.submit();
            },
            rules:{
                msgCode:{
                    required:true,
                },
                cardNum: {
                    required: true,
                },
            },
            messages: {
                msgCode: {
                    required: e + "请输入您收到的手机短信验证码",
                },
                cardNum: {
                    required: e + "请输入您的证件号",
                },
            },
        })
        //新密码验证
        $.validator.setDefaults({
            success: function(e) {
                $(e).next().show();
            },
            highlight: function(e) {
                $(e).siblings('.pswStrCheck').hide();
            },
        });
        $('#setNewPswForm').validate({
            submitHandler:function(form){
                $($('.reg-nav ul li')[3]).attr('class','active')
                $($('.reg-nav ul li')[2]).attr('class','')
                $('#setNewPswForm').hide();
                $('.resetSuccess').show();
                //form.submit();
            },
            rules:{
                password: {
                    required: true,
                    minlength: 6,
                    isSpace:true,
                },
                confirm_password: {
                    required: true,
                    minlength: 6,
                    equalTo: "#Newpassword"
                },
            },
            messages:{
                password: {
                    required: e + "请输入您的密码",
                    minlength: e + "密码必须6个字符以上",
                    isSpace:e+"格式错误"
                },
                confirm_password: {
                    required: e + "请再次输入密码",
                    minlength: e + "密码必须6个字符以上",
                    equalTo: e + "两次输入的密码不一致"
                },
            },
            //success:function(){
            //    if($("#setNewPswForm").validate().element($("#Newpassword"))){
            //        alert(1)
            //    }
            //}
        })
});
        //判断密码的类型
        function CharMode(iN){
            if (iN>=48 && iN <=57) //数字
                return 1;
            if (iN>=65 && iN <=90) //大写
                return 2;
            if (iN>=97 && iN <=122) //小写
                return 4;
            else
                return 8;
        }
        //bitTotal函数
        //计算密码模式
        function bitTotal(num){
            modes=0;
            for (i=0;i<4;i++){
                if (num & 1) modes++;
                num>>>=1;
            }
            return modes;
        }
        //返回强度级别
        function checkStrong(sPW){
            if (sPW.length<=4)
                return 0; //密码太短
            Modes=0;
            for (i=0;i<sPW.length;i++){
        //密码模式
                Modes|=CharMode(sPW.charCodeAt(i));
            }
            return bitTotal(Modes);
        }

        //显示颜色
        function pwStrength(pwd){
            O_color="#fff";
            L_color="#FF0000";
            M_color="#FF9900";
            H_color="#00c800";
            if (pwd==null||pwd==''){
                Lcolor=Mcolor=Hcolor=O_color;
            }
            else{
                S_level=checkStrong(pwd);
                switch(S_level) {
                    case 0:
                        Lcolor=Mcolor=Hcolor=O_color;
                    case 1:
                        Lcolor=L_color;
                        Mcolor=Hcolor=O_color;
                        break;
                    case 2:
                        Lcolor=Mcolor=M_color;
                        Hcolor=O_color;
                        break;
                    default:
                        Lcolor=Mcolor=Hcolor=H_color;
                }
            }
            document.getElementById("strength_L").style.background=Lcolor;
            document.getElementById("strength_M").style.background=Mcolor;
            document.getElementById("strength_H").style.background=Hcolor;
        };